<%@ page import="com.bjfu.gmms.model.Mentor" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>导师个人信息展示</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f3e9ff;
      margin: 0;
      padding: 20px;
    }
    .container {
      width: 80%;
      margin: 0 auto;
      padding: 20px;
      background-color: #ffffff;
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    h1 {
      text-align: center;
      color: #7a49a3;
    }
    .info-form {
      width: 100%;
      margin-top: 20px;
    }
    .info-form label {
      font-weight: bold;
    }
    .info-form input, .info-form textarea {
      width: 100%;
      padding: 10px;
      margin: 10px 0;
      border: 1px solid #ddd;
      border-radius: 4px;
    }
    .info-form img {
      width: 100px;
      height: auto;
      margin-bottom: 10px;
    }
    .info-form button {
      background-color: #7a49a3;
      color: #fff;
      border: none;
      padding: 10px 20px;
      border-radius: 4px;
      cursor: pointer;
    }
    .info-form button:hover {
      background-color: #5b327b;
    }
  </style>
</head>
<body>
<div class="container">
  <h1>导师个人信息维护</h1>
  <%
    Mentor mentor = (Mentor) session.getAttribute("mentor");
    if (mentor == null) {
      out.print("<p>未找到导师信息。</p>");
    } else {
  %>
  <form class="info-form" method="post" action="updateMentorInfoServlet">
    <label for="mentorId">导师编号</label>
    <input type="text" id="mentorId" name="mentorId" value="<%= mentor.getMentorId() %>" readonly />

    <label for="mentorName">导师姓名</label>
    <input type="text" id="mentorName" name="mentorName" value="<%= mentor.getMentorName() %>" />

      <label for="mentorImg">导师头像</label>
      <br>
      <% if (mentor.getMentorImg() != null && !mentor.getMentorImg().isEmpty()) { %>
      <img src="${pageContext.request.contextPath}/imgs/${mentor.getMentorImg()}" alt="导师头像" style="max-width: 150px; max-height: 150px; border-radius: 8px;">
      <% } %>
      <br>

    <label for="mentorDetails">导师简介</label>
    <textarea id="mentorDetails" name="mentorDetails" rows="5"><%= mentor.getMentorDetails() %></textarea>

    <label for="mentorMail">导师邮箱</label>
    <input type="email" id="mentorMail" name="mentorMail" value="<%= mentor.getMentorMail() %>" />

    <label for="mentorPhone">导师电话</label>
    <input type="text" id="mentorPhone" name="mentorPhone" value="<%= mentor.getMentorPhone() %>" />

    <button type="submit">保存修改</button>
  </form>
  <%
    }
  %>
    <div class="file-upload">
        <form action="${pageContext.request.contextPath}/upload" method="POST" enctype="multipart/form-data">
            <input type="hidden" name="mentorId" value="<%= mentor.getMentorId() %>" />
            <input type="file" id="mentorImg" name="mentorImg" />
            <button type="submit">上传并保存</button>
        </form>
    </div>
</div>
</body>
</html>